package com.foreknow.demo4;

import java.util.Scanner;

/**
 * 从控制台录入3次学生信息(学号、姓名、年龄、所在学校)，并将每个学生信息保存到对象中。
 */
public class Student {
    //属性
    int sid;
    String name;
    int age;
    String school;
    //方法
    public void showInfo() {
        System.out.println(sid + "--" + name + "--" + age + "--" + school);
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

            for(int i = 1;i<=2;i++){
                Student s = new Student();
                System.out.println("请输入学号: ");
                int sid = input.nextInt();
                s.sid = sid;
                System.out.println("请输入姓名: ");
                String name = input.next();
                s.name = name;
                System.out.println("请输入年龄: ");
                int age = input.nextInt();
                s.age = age;
                System.out.println("请输入所在学校: ");
                String school = input.next();
                s.school = school;
            s.showInfo();
        }

    }
}
